
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets" template="/template/main.xhtml">

	<ui:define name="body">
		<h:form  prependId="false">
			<p:toolbar>
				<p:toolbarGroup align="left">
					<p:commandButton  title="#{messages['button.new']}" icon="ui-icon-document" action="#{recebimentoListMB.getNextView}"
						actionListener="#{recebimentoListMB.clear}" ajax="false" />

					<p:commandButton  title="#{messages['button.delete']}" icon="ui-icon-trash" onclick="confirmation.show()"
						type="button" immediate="true" ajax="false" />

					<p:dialog style="position: absolute; left:50px; top:50px;"  message="#{messages['label.confirm.delete']}" showEffect="bounce" hideEffect="explode"
						header="#{messages['label.dialog.alert']}!" severity="alert" widgetVar="confirmation">

						<h:commandButton value="#{messages['button.dialog.yes']}" action="#{recebimentoListMB.deleteSelection}"
							actionListener="#{recebimentoListMB.clear}" />
						<h:commandButton value="#{messages['button.dialog.no']}" onclick="confirmation.hide()" type="button" />
					</p:dialog>
				</p:toolbarGroup>
			</p:toolbar>
			
						<br />
		
			<p:fieldset style="width:98%; -webkit-border-radius: 8px; -moz-border-radius: 8px;border-radius: 8px;" legend="#{messages['filtrar']}" toggleable="true" toggleSpeed="500">	
				<h:panelGrid columns="2">

					<h:outputLabel value="#{messages['recebimento.label.usuario']}: " for="usuario" styleClass="text-input" />
					<h:panelGrid columns="2">
						<h:selectOneMenu value="#{recebimentoListMB.usuario}" id="usuario" style="width: 350px;"
							title="#{messages['recebimetno.label.usuario']}"
>
							<f:selectItem itemLabel="Selecione" itemValue="" />
	 						<f:selectItems value="#{recebimentoListMB.usuarios}"></f:selectItems>
						</h:selectOneMenu>
						<p:message for="usuario" />
					</h:panelGrid>

					<h:outputLabel value="#{messages['recebimento.label.cliente']}: " for="cliente" styleClass="text-input" />
					<h:panelGrid columns="2">
						<h:selectOneMenu value="#{recebimentoListMB.cliente}" id="cliente" style="width: 350px;"
							title="#{messages['recebimento.label.cliente']}"
>
							<f:selectItem itemLabel="Selecione" itemValue="" />
	 						<f:selectItems value="#{recebimentoListMB.clientes}"></f:selectItems>
						</h:selectOneMenu>
						<p:message for="cliente" />
					</h:panelGrid>

					<h:outputLabel value="#{messages['recebimento.label.dataRecebimento']}: " for="dataRecebimentoInicial" styleClass="text-input" />
					<h:panelGrid columns="5">
						<p:calendar id="dataRecebimentoInicial" value="#{recebimentoListMB.dataRecebimentoInicial}"  
						   	pattern="#{messages['label.date.pattern']}" navigator="true" showButtonPanel="true"
						   	locale="#{currentLocale}" title="#{messages['recebimento.alt.dataRecebimento']}" />
						<p:message for="dataRecebimentoInicial" />

						<h:outputLabel value=" a " for="dataRecebimentoFinal" styleClass="text-input" />
						<p:calendar id="dataRecebimentoFinal" value="#{recebimentoListMB.dataRecebimentoFinal}"  
						   	pattern="#{messages['label.date.pattern']}" navigator="true" showButtonPanel="true"
						   	locale="#{currentLocale}" title="#{messages['recebimento.alt.dataRecebimentoFinal']}" />
						<p:message for="dataRecebimentoFinal" />
					</h:panelGrid>

				</h:panelGrid>

			    <h:commandButton value="#{messages['button.pesquisar']}" action="#{recebimentoListMB.filtrar}" actionListener="#{recebimentoListMB.filtrar}" ajax="false" >
		    		<f:ajax execute="list" render="list" />
		    	</h:commandButton>
			</p:fieldset>

			<br />
			
			<div style="overflow: auto; width: 100%; height: 600;"> <p:dataTable id="list" var="bean" value="#{recebimentoListMB.resultList}">
				<f:facet name="header">#{messages['recebimento.list.table.title']}</f:facet>
				<p:column style="width:1%;">
					<h:selectBooleanCheckbox value="#{recebimentoListMB.selection[bean.id]}" ></h:selectBooleanCheckbox>
				</p:column>

				<p:column style="width:5%;font-size:12;" >
					<f:facet name="header">Imprimir</f:facet>
					<h:commandLink actionListener="#{recebimetnoListMB.carregarPedido}">
						<a href="ExibeRecebimentoServlet.jsf?idRecebimento=#{bean.id}" target="recebimento" >Imprimir</a>
						<f:param name="idRecebimento" value="#{bean.id}" />
					</h:commandLink>	
				</p:column>
				
				
				<p:column style="width:5%;font-size:12;" >
					<f:facet name="header">Download Excel</f:facet>
					<a href="rest/ServicosExternos/gerarExcelRecebimento?idRecebimento=#{bean.id}" target="_blank" >Download Excel</a>
					<f:param name="#{pedidoListMB.idPedido}" value="#{bean.id}" />
				</p:column>
				
				<p:column style="width:5%;font-size:12;" sortBy="#{bean.id}">
					<f:facet name="header">#{messages['recebimento.label.id']}</f:facet>
					<h:outputText value="#{bean.id}" />
				</p:column>
						
				<p:column style="font-size:12;" sortBy="#{bean.cliente.nome}">
					<f:facet name="header">#{messages['recebimento.label.cliente']}</f:facet>
					<h:commandLink action="#{recebimentoListMB.getNextView}" actionListener="#{recebimentoListMB.clear}">
						<h:outputText value="#{bean.cliente.nome}"    />
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>

				<p:column style="font-size:12;" sortBy="#{bean.usuario.nome}">
					<f:facet name="header">#{messages['recebimento.label.usuario']}</f:facet>
					<h:commandLink action="#{recebimentoListMB.getNextView}" actionListener="#{recebimentoListMB.clear}">
						<h:outputText value="#{bean.usuario.nome}"    />
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>
	
				<p:column style="font-size:12;" sortBy="#{bean.dataRecebimento}">
					<f:facet name="header">#{messages['recebimento.label.dataRecebimento']}</f:facet>
					<h:commandLink action="#{recebimentoListMB.getNextView}" actionListener="#{recebimentoListMB.clear}">
						<h:outputText value="#{bean.dataRecebimento}"   converter="dateConverter" />
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>
						
				<p:column style="font-size:12;" sortBy="#{bean.formaRecebimento.descricao}">
					<f:facet name="header">#{messages['recebimento.label.formaRecebimento']}</f:facet>
					<h:commandLink action="#{recebimentoListMB.getNextView}" actionListener="#{recebimentoListMB.clear}">
						<h:outputText value="#{bean.formaRecebimento.descricao}" />
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>
						
				<p:column style="font-size:12;" sortBy="#{bean.valorTotalRecebimento}">
					<f:facet name="header">#{messages['recebimento.label.valorTotalRecebimento']}</f:facet>
					<h:commandLink action="#{recebimentoListMB.getNextView}" actionListener="#{recebimentoListMB.clear}">
						<h:outputText value="#{bean.valorTotalRecebimento}" converter="bigDecimalConversor" />
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>
				
				<p:column style="font-size:12;" sortBy="#{bean.conferido}">
					<f:facet name="header">#{messages['recebimento.label.conferido']}</f:facet>
					<h:commandLink action="#{recebimentoListMB.getNextView}" actionListener="#{recebimentoListMB.clear}">
						<h:outputText value="Sim" rendered="#{bean.conferido}"/>
						<h:outputText value="Não" rendered="#{!bean.conferido}"/>
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>

			</p:dataTable></div>

			<h:panelGrid columns="2">   
 					<h:commandLink immediate="true">  
			            <input type="button" title="Exportar" value="Exportar"/>  
			            <p:dataExporter postProcessor="#{recebimentoListMB.postProcessXLS}" type="xls" target="list" fileName="dados_exportados"  />  
			        </h:commandLink>			</h:panelGrid>

		</h:form>

	</ui:define>
</ui:composition>